package com.ssm.lzh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.hj.page.Page;
import com.ssm.lzh.service.ProjectService;
import com.ssm.lzh.vo.projectvo;
import com.ssm.mapper.ProjectMapper;
import com.ssm.pojo.Project;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProjectServiceImpl implements ProjectService {

    @Resource
    private ProjectMapper projectMapper;


    @Override
    public PageInfo<Project> queryAllProject(Page<Project> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        return new PageInfo<Project>(this.projectMapper.queryAllProject(page.getSearchObj())) ;
    }

    @Override
    public int addProject(projectvo<Project> projectvo) {
       this.projectMapper.addProject(projectvo.getObj());
        System.out.println(projectvo.getObj());
       this.projectMapper.insertpro_jcx(projectvo);
        return 0;
    }

    @Override
    public List<Project> queryAllPro() {
        return this.projectMapper.queryAllPro();
    }

    @Override
    public int updateProject(projectvo<Project> projectvo) {
        this.projectMapper.updateProject(projectvo.getObj());
        this.projectMapper.deletepro_jcx(projectvo.getObj().getPid());
        this.projectMapper.insertpro_jcx(projectvo);
        return 0;
    }
}
